package com.pb.infra.param.controller;


import com.pb.infra.oth.entity.common.Page;
import com.pb.infra.oth.entity.common.Result;
import com.pb.infra.oth.util.Constant;
import com.pb.infra.oth.util.SysLog;
import com.pb.infra.param.entity.pbbase.CapBaseInfoConfig;
import com.pb.infra.param.service.CapBaseInfoConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ filename:
 * @ description:
 * @ author:lzy
 * @ version:1.0.0
 */
//@Controller("system/base")
@Slf4j
@RequestMapping("/CapBaseInfo")
@RestController
public class CapBaseInfoConfigController {
    @Resource
    CapBaseInfoConfigService capBaseInfoConfigService;

    /**
     * 日志操作表
     */
    private static final String TABLE_NAME = "CAP_BASE_INFO_CONFIG";

    /**
     * 日志操作功能名
     */
    private static final String OPERATION_MENU = "基础信息配置";

    @GetMapping("select")
    @SysLog(tableName=TABLE_NAME,action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result select(@RequestParam Map<String, Object> map, Page page){
        return capBaseInfoConfigService.select(map, page);
    }

    @PostMapping("delete")
    @SysLog(tableName=TABLE_NAME,action = Constant.ACTION_NAME.DEL, menuName = OPERATION_MENU)
    public Result delete(@RequestBody List<String> paramMap){
        try {
            capBaseInfoConfigService.delete(paramMap);
        } catch (Exception e) {
            return Result.error("-1","删除失败");
        }
        return Result.OK_EMPTY;
    }

    @PostMapping("update")
    @SysLog(tableName="cap_base_info_config",action = Constant.ACTION_NAME.UP)
    public Result update(@RequestBody CapBaseInfoConfig capBaseInfoConfig){
        
        return capBaseInfoConfigService.update(capBaseInfoConfig);
    }


    @PostMapping("insert")
    @SysLog(tableName=TABLE_NAME,action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result insert(@RequestBody CapBaseInfoConfig capBaseInfoConfig){
        return capBaseInfoConfigService.insert(capBaseInfoConfig);
    }
}
